package day319.demo1;

import day319.demo1.Father;
import day319.demo1.GrandSon;
import day319.demo1.Son;

public class Test {
    public static void main(String[] args) {

        Father grandSon1 = new GrandSon();
        Father grandSon2 = new Son();

        if (grandSon1 instanceof GrandSon){
            GrandSon grandSon = (GrandSon) grandSon1;
            System.out.println("Father类型 成功 强制转换成GrandSon类型");
            grandSon.toString("小王",12);
        }else {
            System.out.println("Father类型的grandSon1转换成Son类型失败!");
        }

        if (grandSon1 instanceof Son ){
            Son son = (Son) grandSon2;
            System.out.println();
            System.out.println("Father类型 成功 强制转换成Son类型");
            son.toString("小李",25);
        }else {
            System.out.println("Father类型的grandSon1转换成Son类型失败!");
        }

        if (grandSon2 instanceof GrandSon){
            GrandSon father = (GrandSon) grandSon2;
            System.out.println();
            System.out.println("Father类型 成功 强制转换成GrandSon类型");
            father.toString("小张",35);
        }else {
            System.out.println();
            System.out.println("Father类型的grandSon1转换成GrandSon类型失败!");
        }










    }
}
